#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int StrToInt(string str) {
        int n = 0, t = 1, flag = 1;
        for (int i = str.size() - 1; i >= 0; i--)
        {
            if (str[i] == '+' || str[i] == '-')
            {
                if (str[i] == '-')
                    flag = -1;
                break;
            }
            if (str[i] >= '0' && str[i] <= '9')
            {
                n += (str[i] - '0') * t;
                t *= 10;
            }
            else
                return 0;
        }
        return n * flag;
    }
};